<template>
    <el-container class="contain">
      <el-container>
        <el-aside width="200px">
          <el-menu :default-openeds="['1']">
            <el-submenu index="1">
              <template #title>来源平台</template>
              <el-menu-item style="background-color: rgba(126, 175, 151, 0.132) ;font-size: 15px;font-weight: bold; " index="1-1">抖音</el-menu-item>
              <el-menu-item style="background-color: rgba(126, 175, 151, 0.132) ;font-size: 15px;font-weight: bold; " index="1-2">B站</el-menu-item>
              <el-menu-item style="background-color: rgba(126, 175, 151, 0.132) ;font-size: 15px;font-weight: bold; " index="1-3">其他</el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <el-form :model="videoForm" label-width="80px">
            <el-form-item label="视频链接">
              <el-input v-model="videoForm.originalLink" placeholder="请输入原视频链接"></el-input>
            </el-form-item>
            <el-form-item label="标题">
              <el-input v-model="videoForm.title" placeholder="请输入标题"></el-input>
            </el-form-item>
            <el-form-item label="标签">
              <el-input type="textarea" v-model="videoForm.tags" placeholder="请输入标签，用逗号分隔"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="repostVideo">转载视频</el-button>
            </el-form-item>
          </el-form>
          <el-table :data="videoList" style="width: 100%; margin-top: 20px;">
            <el-table-column prop="title" label="标题"></el-table-column>
            <el-table-column prop="tags" label="标签"></el-table-column>
            <el-table-column label="操作">
              <template  v-slot="scope">
                <el-button type="text" @click="previewVideo(scope.row)">预览</el-button>
                <el-button type="text" @click="editVideo(scope.row)">编辑</el-button>
                <el-button type="text" @click="deleteVideo(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
      <el-footer>版权所有 @智思云有限公司</el-footer>
    </el-container>
  </template>
  
  <script>
  export default {
    data() {
      return {
        videoForm: {
          originalLink: '',
          title: '',
          tags: ''
        },
        videoList: []
      };
    },
    methods: {
      repostVideo() {
        if (this.videoForm.originalLink && this.videoForm.title) {
          const newVideo = {
          ...this.videoForm
          };
          this.videoList.push(newVideo);
          this.videoForm.originalLink = '';
          this.videoForm.title = '';
          this.videoForm.tags = '';
          this.$message.success('视频转载成功');
        } else {
          this.$message.warning('请填写原视频链接和标题');
        }
      },
      previewVideo(video) {
        // 这里可以添加预览视频的逻辑，比如弹出模态框显示视频信息等，此处仅模拟
        this.$message.info(`正在预览视频: ${video.title}`);
      },
      editVideo(video) {
        // 可以添加编辑视频信息的逻辑，比如弹出表单填充已有信息进行编辑
        this.$message.info(`正在编辑视频: ${video.title}`);
      },
      deleteVideo(video) {
        const index = this.videoList.findIndex(v => v === video);
        if (index!== -1) {
          this.videoList.splice(index, 1);
          this.$message.success('视频已删除');
        }
      }
    }
  };
  </script>
  
  <style scoped>
  .contain{
    height: auto;
    width: 1345px;
    margin-left: 180px;
    background-color: rgba(126, 175, 151, 0.132);
  }
  </style>